<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
</head>
<body>
<ul class="layui-nav layui-bg-green" lay-filter="">
    <li class="layui-nav-item"><a href="/room/mahjong/user_main">房间列表</a></li>
    <li class="layui-nav-item layui-this"><a href="/room/findTypes">我的订单</a></li>
    <li class="layui-nav-item layui-col-md-offset7"><a th:text="${session.user.nickname}"></a></li>
    <li class="layui-nav-item"><a href="/account/logout">退出</a></li>
</ul>
<div class="layui-container" style="width: 960px;height: 600px;margin-top: 0px;padding-top: 60px;">
    <table class="layui-hide" id="test" lay-filter="test"></table>
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <script>
        layui.use('table', function(){
            var table = layui.table;

            table.render({
                elem: '#test'
                ,url:'/order/findAllByUid'
                ,title: '订单列表'
                ,cols: [
                    [
                        {field:'id', width:100, title: '编号', sort: true}
                        , {
                        field: 'name', width: 200, title: '房间名', templet: function (data) {
                                return data.room.name
                            }
                        }
                        , {
                        field: 'price', width: 100, title: '价格', templet: function (data) {
                                return data.room.price
                            }
                        }
                        ,{field:'size', width:100, title: '大小',templet:function(data){
                                return data.room.size
                            }
                        }
                        ,{field:'date',width:300,  title: '下单时间'}
                        ,{field:'state', width:160, title: '订单状态',templet:function(data){
                                var result = "";
                                switch (data.state) {
                                    case 0:
                                        result = "待使用";
                                        break;
                                    case 1:
                                        result = "已消费";
                                        break;
                                }
                                return result
                            }
                        }
                    ]
                ]
                ,page: true
            });


        });
    </script>
</div>

</body>
</html>